package org.jfbmonitor.view.statement;

import java.awt.FontMetrics;
import javax.swing.table.DefaultTableColumnModel;
import javax.swing.table.TableColumn;

import org.jfbmonitor.language.Language;

public class StatementColumnModel extends DefaultTableColumnModel {	
	private static final long serialVersionUID = 1L;
	
	
	public StatementColumnModel(FontMetrics fm){
		int number = fm.stringWidth("0");
		int character = fm.stringWidth("M");
		
		addColumn(createColumn(0, 14 * number, fm, Language.getInstance()
				.getProperties("TABLE.STATEMENTID")));		
		addColumn(createColumn(1, 14 * number, fm, Language.getInstance()
				.getProperties("TABLE.ATTACHMENTID")));		
		addColumn(createColumn(2, 14 * number, fm, Language.getInstance()
				.getProperties("TABLE.TRANSACTIONID")));		
		addColumn(createColumn(3, 6 * character, fm, Language.getInstance()
				.getProperties("TABLE.STATE")));
        addColumn(createColumn(4, 14 * character, fm,Language.getInstance()
                .getProperties("TABLE.TIMESTAMP")));
        addColumn(createColumn(5, 12 * number, fm, Language.getInstance()
				.getProperties("TABLE.STATID")));		
	}
	
	private TableColumn createColumn(int columnIndex, int width,
			FontMetrics fm, String title) {
		TableColumn col = new TableColumn(columnIndex);
		col.setCellRenderer(new StatementCellRenderer());
		col.setHeaderRenderer(null);
		col.setHeaderValue(title);
		col.setResizable(true);
		col.setMinWidth(0);
		col.setMaxWidth(width);
		return col;
	}

	

}
